package edu.clarkson.ee368.spring2012.coreservices;

import java.io.Serializable;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQuery;
import javax.persistence.OneToOne;
import javax.persistence.Table;




@Entity
@NamedQuery(
	name="findWithUserAndPassword",
	query="select distinct a from AccountImpl a where a.username = :username and a.password = :password"
)
@Table(name="account")
public class AccountImpl implements Serializable, Account {

	/**
	 * 
	 */
	private static final long serialVersionUID = -5030925335678906264L;
	@Id
	@GeneratedValue(strategy=GenerationType.IDENTITY)
	private long id;
	
	
	private String username;
	
	private String password;

	@OneToOne(cascade=CascadeType.ALL, orphanRemoval=true)
	private Device device;
	
	public AccountImpl() {

	}

	/* (non-Javadoc)
	 * @see edu.clarkson.ee368.spring2012.coreservices.Account#getId()
	 */
	@Override
	public long getId() {
		return id;
	}

	/* (non-Javadoc)
	 * @see edu.clarkson.ee368.spring2012.coreservices.Account#setId(long)
	 */
	@Override
	public void setId(long id) {
		this.id = id;
	}

	/* (non-Javadoc)
	 * @see edu.clarkson.ee368.spring2012.coreservices.Account#getUserName()
	 */
	@Override
	public String getUserName() {
		return username;
	}

	/* (non-Javadoc)
	 * @see edu.clarkson.ee368.spring2012.coreservices.Account#setUserName(java.lang.String)
	 */
	@Override
	public void setUserName(String username) {
		this.username = username;
	}

	/* (non-Javadoc)
	 * @see edu.clarkson.ee368.spring2012.coreservices.Account#getDevice()
	 */
	@Override
	public Device getDevice() {
		return device;
	}

	/* (non-Javadoc)
	 * @see edu.clarkson.ee368.spring2012.coreservices.Account#setDevice(edu.clarkson.ee368.spring2012.coreservices.Device)
	 */
	@Override
	public void setDevice(Device device) {
		this.device = device;
	}
	
	/* (non-Javadoc)
	 * @see edu.clarkson.ee368.spring2012.coreservices.Account#getPassword()
	 */
	@Override
	public String getPassword() {
		return this.password;
	}
	
	/* (non-Javadoc)
	 * @see edu.clarkson.ee368.spring2012.coreservices.Account#setPassword(java.lang.String)
	 */
	@Override
	public void setPassword(String password) {
		this.password = password;
	}

}
